package composantes;

public class Cellule {
	private int _etat,
				_type,
				_x,
				_y;
	
	public Cellule(){
		_etat = _type = _x = _y = 0;
	}
	
	public Cellule(int etat, int type, int x, int y){
		_etat = etat;
		_type = type;
		_x = x;
		_y = y;
	}
	
	public Cellule(int x, int y){
		_x = x;
		_y = y;
	}
	
	public int getEtat(){
		return _etat;
	}
	
	public int getType(){
		return _type;
	}
	
	public int getX(){
		return _x;
	}
	
	public int getY(){
		return _y;
	}
	
	public void setEtat(int etat){
		_etat = etat;
	}
	
	public void setType(int type){
		_type = type;
	}
	
	public void init(int etat, int type){
		_etat = etat;
		_type = type;
	}
	
	public boolean estVoisin(Cellule c){
		if(_x == c.getX()){
			if(_y == c.getY()+1 || _y == c.getY()-1)
				return true;
		}else if(_y == c.getY()){
			if(_x == c.getX()+1 || _x == c.getX()-1)
				return true;
		}
		return false;
			
	}
	
	public boolean peutGagnerEtat(){
		return _etat < 2;
	}
	
	public boolean peutPerdreEtat(){
		return _etat > 0;
	}
	
	public boolean gagnerEtat(){
		if(peutGagnerEtat()){
			_etat++;
			return true;
		}else
			return false;
	}
	
	public boolean perdreEtat(){
		if(peutPerdreEtat()){
			_etat--;
			return true;
		}else
			return false;
	}
}
